import os

# 和操作系统交互

print(os.name)  # posix - linux  nt - windows

print(os.getenv("PATH"))  # 环境变量

print(os.path.split("C:/Users/lesliesu/web-python-2025"))

print(os.path.dirname("C:/Users/lesliesu/web-python-2025"))  # C:/Users/lesliesu
print(
    os.path.basename("C:/Users/lesliesu/web-python-2025")
)  # web-python-2025 # 路径以斜杠结尾返回空值

print(os.path.exists("/Users/lesliesu/web-python-2025"))  # True
print(os.path.exists("/Users/lesliesu/web-python-2025"))  # True
print(os.path.isdir("/Users/lesliesu/web-python-2025"))  # True
print(os.path.isfile("/Users/lesliesu/web-python-2025"))  # False
print(os.path.abspath("os_01.py"))  # /Users/lesliesu/web-python-2025/v_os/os_01.py
print(os.path.splitext("os_01.py"))  # (os_01, .py)
print(os.path.splitext("os_01.py")[1].replace(".", ""))  # py
